/**
 *  TinyPasswordManager
 *  Copyright (C) 2008 Gross David <gdavid.devel@gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#include "firefoxpassworddialog.h"

#include <QtGui/QGridLayout>
#include <string>

FirefoxPasswordDialog::FirefoxPasswordDialog(QWidget *parent)
    : QDialog(parent) {    
    init();
    createConnections();
}

FirefoxPasswordDialog::~FirefoxPasswordDialog() {
}

void FirefoxPasswordDialog::createConnections() {
    connect(m_buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
    connect(m_buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
}

void FirefoxPasswordDialog::init() {
    QLabel *labelPassword = new QLabel(tr("Master password: "));
    m_editPassword = new QLineEdit("");
    m_editPassword->setEchoMode(QLineEdit::Password);
    m_editPassword->setFocus();
    m_buttonOk = new QPushButton(tr("Ok"));
    m_buttonCancel = new QPushButton(tr("Cancel"));
    
    QGridLayout *layout = new QGridLayout();
    layout->addWidget(labelPassword, 0, 0);
    layout->addWidget(m_editPassword, 0, 1);
    layout->addWidget(m_buttonOk, 1, 0);
    layout->addWidget(m_buttonCancel, 1, 1);
    
    setLayout(layout);
}

std::string FirefoxPasswordDialog::getMasterPassword() const {
    return m_editPassword->text().toStdString();
}
